<ul id="setting-nav" class="container text-center">
    <li><a href="#general">基本</a></li>
    <li><a href="#content">内容</a></li>
    <li><a href="#nav">导航</a></li>
    <li><a href="#custom">自定义</a></li>
</ul>
<div id="setting-panels" class="container">
    <form id="setting-form" class="setting-form form form-align setting-panel" action="/admin/setting/" method="post">
        <p class="item">
            <label for="site-url">站点地址</label>
            <input id="site-url" class="ipt" type="url" name="site_url" required="required" value="{{Setting `site_url`}}"/>
        </p>
        <p class="item">
            <label for="site-title">站点主标题</label>
            <input id="site-title" class="ipt" type="text" name="site_title" required="required" value="{{Setting `site_title`}}"/>
        </p>
        <p class="item">
            <label for="site-sub-title">站点副标题</label>
            <input id="site-sub-title" class="ipt" type="text" name="site_sub_title" required="required" value="{{Setting `site_sub_title`}}"/>
        </p>
        <p class="item">
            <label for="site-keywords">Meta关键字</label>
            <input id="site-keywords" class="ipt" type="text" name="site_keywords" value="{{Setting `site_keywords`}}"/>
        </p>
        <p class="item">
            <label for="site-desc">Meta站点介绍</label>
            <input id="site-desc" class="ipt" type="text" name="site_description" value="{{Setting `site_description`}}"/>
        </p>
        <p>
            <label>&nbsp;</label>
            <button class="btn btn-blue">保存</button>
        </p>
    </form>
    <form id="setting-content-form" class="setting-form form form-align setting-panel" action="/admin/setting/" method="post">
        <p class="item">
            <label for="article-size">单页文章列表数</label>
            <input id="article-size" class="ipt" type="number" name="article_size" value="{{Setting `article_size`}}" max="10" min="3" required="required"/>
        </p>
        <p class="item">
            <label for="popular-size">热评文章列表数</label>
            <input id="popular-size" class="ipt" type="number" name="popular_size" value="{{Setting `popular_size`}}" max="10" min="3"  required="required"/>
        </p>
        <p class="item">
            <label for="recent-comment-size">最近评论列表数</label>
            <input id="recent-comment-size" class="ipt" type="number" name="recent_comment_size" value="{{Setting `recent_comment_size`}}" max="10" min="3" required="required"/>
        </p>
        <p class="item">
            <label for="go-markdown">Go渲染Markdown</label>
            <input id="go-markdown" class="ipt" type="text" name="enable_go_markdown" value="{{Setting `enable_go_markdown`}}"/>
            <span class="tip block">默认关闭，使用前端marked.js渲染，填true时开启</span>
            <input type="hidden" name="enable_go_markdown_def" value="false"/>
        </p>
        <p>
            <label>&nbsp;</label>
            <button class="btn btn-blue">保存</button>
        </p>
    </form>
    <form id="setting-nav-form" class="setting-form form form-align setting-panel" action="/admin/setting/nav/" method="post">{{range .Navigators}}
        <p class="item">
            <span class="label">排序</span><input class="ipt order" type="number" name="order" value="{{.Order}}"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <span class="label">文本</span><input class="ipt text" type="text" name="text" value="{{.Text}}" required="required"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <span class="label">标题</span><input class="ipt title" type="text" name="title" value="{{.Title}}"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <span class="label">链接</span><input class="ipt link" type="text" name="link" value="{{.Link}}" required="required"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="del" href="#">删除</a>
        </p>{{end}}
        <p>
            <button class="btn btn-blue">保存</button>&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="lbl lbl-green add" href="#" rel="#nav-item">添加一项</a>
        </p>
        <script type="text/template" id="nav-item">
            <p class="item">
                <span class="label">排序</span><input class="ipt order" type="number" name="order" value="1"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <span class="label">文本</span><input class="ipt text" type="text" name="text" value="" required="required"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <span class="label">标题</span><input class="ipt title" type="text" name="title" value=""/>&nbsp;&nbsp;&nbsp;&nbsp;
                <span class="label">链接</span><input class="ipt link" type="text" name="link" value="" required="required"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <a class="del" href="#">删除</a>
            </p>
        </script>
    </form>
    <form id="setting-custom-form" class="setting-form form form-align setting-panel" action="/admin/setting/custom/" method="post">{{range $k,$v := .Custom}}
        <p class="item">
            <input class="ipt key" type="text" name="key" value="{{$k}}"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="value" class="ipt value" type="text" value="{{$v}}"/>
            <a class="del" href="#">删除</a>
        </p>{{end}}
        <p>
            <button class="btn btn-blue">保存</button>&nbsp;&nbsp;&nbsp;&nbsp;
            <a class="lbl lbl-green add" href="#" rel="#custom-item">添加一项</a>
            <span class="tip block">使用函数自定义配置，需要加前缀"c_"，如GetSetting("c_key")</span>
        </p>
        <script type="text/template" id="custom-item">
            <p class="item">
                <input class="ipt key" type="text" name="key" placeholder="字段名"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="value" class="ipt value" type="text" placeholder="字段值"/>
                <a class="del" href="#">删除</a>
            </p>
        </script>
    </form>
</div>
<script src="http://libs.baidu.com/jquerytools/1.2.7/jquery.tools.min.js"></script>
<script>
    $(function () {
        $('#setting-nav').tabs(".setting-panel");
        $('.setting-form').ajaxForm(function (json) {
            alert(json.res ? "已保存" : json.msg);
        }).on("click",".add",function(e){
            e.preventDefault();
            $(this).parent().parent().prepend($($(this).attr("rel")).html());
        }).on("click",".del",function(e){
            e.preventDefault();
            if(confirm("要删除这项？")){
                $(this).parent().remove();
            }
        })
    })
</script>